Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / testing / src / commonMain / kotlin / org / meshtastic / core / testing / FakeTracerouteSnapshotRepository.kt

Displaying Raw • Download

core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/FakeTracerouteSnapshotRepository.kt 7730823aad5ffe461199820be209e18d09b0ee07 (7730823a) Text, 2.20 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.testing

Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787kotlinx.coroutines.flow.map
Tff7b72import T7ee787org.meshtastic.core.repository.TracerouteSnapshotRepository
Tff7b72import T7ee787org.meshtastic.proto.Position

T8b949e/**
* A test double for [TracerouteSnapshotRepository] keyed by `logUuid`.
*
* Use [upsertSnapshotPositions] as you would in production, or [seedSnapshot] to directly inject state for a log.
*/
Tff7b72class T56d364FakeTracerouteSnapshotRepository Tb4b4b4:
Te6edf3BaseFakeTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3TracerouteSnapshotRepository Tb4b4b4{

Tff7b72private Tff7b72val Te6edf3snapshots Tff7b72= Te6edf3mutableStateFlowTff7b72<Te6edf3MapTff7b72<Tffa657StringTb4b4b4, Te6edf3MapTff7b72<Tffa657IntTb4b4b4, Te6edf3PositionTff7b72>Tff7b72>Tff7b72>Tb4b4b4(Te6edf3emptyMapTb4b4b4(Tb4b4b4)Tb4b4b4)
Tff7b72private Tff7b72val Te6edf3requestIds Tff7b72= Te6edf3mutableMapOfTff7b72<Tffa657StringTb4b4b4, Tffa657IntTff7b72>Tb4b4b4(Tb4b4b4)

Tff7b72init Tb4b4b4{
Te6edf3registerResetAction Tb4b4b4{ Te6edf3requestIdsTb4b4b4.Te6edf3clearTb4b4b4(Tb4b4b4) Tb4b4b4}
Tb4b4b4}

Tff7b72override Tff7b72fun Td2a8ffgetSnapshotPositionsTb4b4b4(Te6edf3logUuidTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Te6edf3MapTff7b72<Tffa657IntTb4b4b4, Te6edf3PositionTff7b72>Tff7b72> Tff7b72=
Te6edf3snapshotsTb4b4b4.Te6edf3map Tb4b4b4{ Tffa657itTff7b72[Te6edf3logUuidTff7b72]Tb4b4b4.Te6edf3orEmptyTb4b4b4(Tb4b4b4) Tb4b4b4}

Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffupsertSnapshotPositionsTb4b4b4(Te6edf3logUuidTb4b4b4: Tffa657StringTb4b4b4, Te6edf3requestIdTb4b4b4: Tffa657IntTb4b4b4, Te6edf3positionsTb4b4b4: Te6edf3MapTff7b72<Tffa657IntTb4b4b4, Te6edf3PositionTff7b72>Tb4b4b4) Tb4b4b4{
Te6edf3requestIdsTff7b72[Te6edf3logUuidTff7b72] Tff7b72= Te6edf3requestId
Te6edf3snapshotsTb4b4b4.Te6edf3value Tff7b72= Te6edf3snapshotsTb4b4b4.Te6edf3valueTb4b4b4.Te6edf3toMutableMapTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3also Tb4b4b4{ Tffa657itTff7b72[Te6edf3logUuidTff7b72] Tff7b72= Te6edf3positions Tb4b4b4}
Tb4b4b4}

T8b949e/** Directly seeds the snapshot for a log (bypasses request-id tracking). */
Tff7b72fun Td2a8ffseedSnapshotTb4b4b4(Te6edf3logUuidTb4b4b4: Tffa657StringTb4b4b4, Te6edf3positionsTb4b4b4: Te6edf3MapTff7b72<Tffa657IntTb4b4b4, Te6edf3PositionTff7b72>Tb4b4b4) Tb4b4b4{
Te6edf3snapshotsTb4b4b4.Te6edf3value Tff7b72= Te6edf3snapshotsTb4b4b4.Te6edf3valueTb4b4b4.Te6edf3toMutableMapTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3also Tb4b4b4{ Tffa657itTff7b72[Te6edf3logUuidTff7b72] Tff7b72= Te6edf3positions Tb4b4b4}
Tb4b4b4}

T8b949e/** Returns the last request-id recorded for [logUuid], or `null` if none. */
Tff7b72fun Td2a8fflastRequestIdTb4b4b4(Te6edf3logUuidTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657Int? Tff7b72= Te6edf3requestIdsTff7b72[Te6edf3logUuidTff7b72]
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s